//
//  RecordViewController.m
//  Elimination
//
//  Created by A-01 on 2020/7/1.
//  Copyright © 2020 A-01. All rights reserved.
//

#import "RecordViewController.h"

@interface RecordViewController ()

@property (nonatomic, weak)UILabel * titleLabel;
@property (nonatomic, weak)UIView * topView;
@property (nonatomic, weak)UIView * bottomView;
@property (nonatomic, weak)UILabel * bestLabel;
@property (nonatomic, weak)UILabel * bestValueLabel;
@property (nonatomic, weak)UILabel * lastLabel;
@property (nonatomic, weak)UILabel * lastValueLabel;

@end

@implementation RecordViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setupUI];
}


- (void)setupUI{
        
    UILabel * titleLabel = [UILabel new];
        
    titleLabel.text = @"Record";
    titleLabel.textColor = ZRWhiteColor;
    titleLabel.font = [UIFont fontWithName:@"FZSEJW--GB1-0" size:30];
        
    self.titleLabel = titleLabel;
        
    [self.view addSubview:self.titleLabel];

    
    UIView * bottomView = [UIView new];
    
    bottomView.backgroundColor = ZRWhiteColor;
    bottomView.alpha = 0.8;
    
    self.bottomView = bottomView;
    
    [self.view addSubview:self.bottomView];
    
    
    UIView * topView = [UIView new];
    
    topView.backgroundColor = ZRWhiteColor;
    
    self.topView = topView;
    
    [self.view addSubview:self.topView];
    
    
    UILabel * bestLabel = [UILabel new];
    
    bestLabel.textColor = ZRBlackColor;
    bestLabel.font = [UIFont systemFontOfSize:17];
    bestLabel.textAlignment = NSTextAlignmentCenter;
    bestLabel.text = @"Best Score";
    
    self.bestLabel = bestLabel;
    
    [self.view addSubview:self.bestLabel];
    
    
    UILabel * lastLabel = [UILabel new];
    
    lastLabel.textColor = ZRBlackColor;
    lastLabel.font = [UIFont systemFontOfSize:17];
    lastLabel.textAlignment = NSTextAlignmentCenter;
    lastLabel.text = @"Last Score";
    
    self.lastLabel = lastLabel;
    
    [self.view addSubview:self.lastLabel];
    
    
    UILabel * bestValueLabel = [UILabel new];
    
    bestValueLabel.textColor = [UIColor colorWithHexString:@"ED5151"];
    bestValueLabel.font = [UIFont boldSystemFontOfSize:48];
    bestValueLabel.textAlignment = NSTextAlignmentCenter;
    bestValueLabel.text = DEF_GET_OBJECT(@"best") ? DEF_GET_OBJECT(@"best") : @"00";
    
    self.bestValueLabel = bestValueLabel;
    
    [self.view addSubview:self.bestValueLabel];
    
    
    UILabel * lastValueLabel = [UILabel new];
    
    lastValueLabel.textColor = [UIColor colorWithHexString:@"4198FF"];
    lastValueLabel.font = [UIFont boldSystemFontOfSize:48];
    lastValueLabel.textAlignment = NSTextAlignmentCenter;
    lastValueLabel.text = DEF_GET_OBJECT(@"last") ? DEF_GET_OBJECT(@"last") : @"00";
    
    self.lastValueLabel = lastValueLabel;
    
    [self.view addSubview:self.lastValueLabel];
}


-(void)viewDidLayoutSubviews{
    
    [super viewDidLayoutSubviews];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(self.view).offset(40);
    }];
    
    [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.bottom.mas_equalTo(self.view).offset(-55);
        make.width.mas_equalTo(325);
        make.height.mas_equalTo(115);
    }];
    
    [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.bottom.mas_equalTo(self.bottomView.mas_top);
        make.width.mas_equalTo(325);
        make.height.mas_equalTo(115);
    }];
    
    [self.bestLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.topView);
        make.top.mas_equalTo(self.topView).offset(28);
    }];
    
    [self.bestValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.topView);
        make.top.mas_equalTo(self.bestLabel.mas_bottom);
    }];
    
    [self.lastLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.bottomView);
        make.top.mas_equalTo(self.bottomView).offset(20);
    }];
    
    [self.lastValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.bottomView);
        make.top.mas_equalTo(self.lastLabel.mas_bottom);
    }];
    
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.topView.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(20, 20)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = self.topView.bounds;
    maskLayer.path = maskPath.CGPath;
    [self.topView.layer addSublayer:maskLayer];
    self.topView.layer.mask = maskLayer;
    self.topView.layer.masksToBounds = YES;
    
    UIBezierPath *maskPathBottom = [UIBezierPath bezierPathWithRoundedRect:self.bottomView.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(20, 20)];
    CAShapeLayer *maskLayerBottom = [[CAShapeLayer alloc] init];
    maskLayerBottom.frame = self.topView.bounds;
    maskLayerBottom.path = maskPathBottom.CGPath;
    [self.bottomView.layer addSublayer:maskLayerBottom];
    self.bottomView.layer.mask = maskLayerBottom;
    self.bottomView.layer.masksToBounds = YES;
}
    
@end
